package com.ffly.list;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MainActivity extends ListActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new listAdapter());
		this.getListView().setSelector(R.drawable.list_selector_background_even);//自定义选中效果
	//	this.getListView().setSelector(android.R.drawable.list_selector_background);//系统选中效果
	}

	class listAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			return 100;
		}

		@Override
		public Object getItem(int position) {
			return position;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			TextView tv = new TextView(getApplicationContext());
			tv.setText(position + "");
			if((position&1)!=0){//单双行效果区分
				tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.xxxa));
			}
			return tv;
		}

	}
}